﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FlexiCommerce.Web.Addons.FC.Items
{
    public abstract class AbstractDataBoundStoreItem: AbstractStoreItem
    {
        public const string EmptyDataItemTemplateUrl = "~/Addons/FlexiCommerce/UI/Parts/EmptyDataItem.ascx";
        private bool? isDataBound = null;
        public bool DataBound
        {
            get
            {
                if (isDataBound == null)
                {
                    isDataBound = DoesDataBoundItemExist();
                }
                return (bool)isDataBound;
            }
        }
        public abstract bool DoesDataBoundItemExist();

        public override string TemplateUrl
        {
            get
            {
                if(DataBound)
                    return base.TemplateUrl;
                return EmptyDataItemTemplateUrl;
            }
        }

    }
}
